#pragma once

#include <libge/libge.h>

typedef struct mc_Vertex_Fast {
	short x, y, z;
	short anim;
	u8 color[4];
	short u, v;
} mc_Vertex_Fast;

typedef struct mc_Vertex_Basic {
	float x, y, z;
	char nx, ny, nz, z__align1;
	u8 color[4];
	float u, v;
	float anim_mode;
} mc_Vertex_Basic;

typedef struct mc_Vertex {
	float x, y, z;
	char nx, ny, nz, z__align1;
	u8 color[4];
	float u, v;
	u8 anim_mode;
	u8 light;
	u8 specular;
	u8 z__align2;
} mc_Vertex;

class Client;
class Block;
class Material;

class BlockRender {
public:
	BlockRender(Client* cli, Chunk* chu, float side = 1.0);
	bool Generate(Block* block, Block* north, Block* south, Block* east, Block* west, Block* up, Block* down, mc_Vertex* verts[6], int** vi, float x, float y, float z, float height);
	void GenerateCube(float height, bool north, bool south, bool east, bool west, bool up, bool down, u8* verts[6], int** vi, float x, float y, float z);
	void MakeVertex(void* vert, int face, int biome_colored, u8 light, float x, float y, float z, float tx, float ty, float nx, float ny, float nz);
	void SetBlock(Block* b);
	void ForceMaterial(Material* m);

private:
	void GenerateSpriteVolume(float height, bool north, bool south, bool east, bool west, bool up, bool down, u8* verts[6], int** vi, float x, float y, float z);
	void GenerateStairs(float height, bool north, bool south, bool east, bool west, bool up, bool down, u8* verts[6], int** vi, float x, float y, float z);
	void GenerateRail(float height, bool north, bool south, bool east, bool west, bool up, bool down, u8* verts[6], int** vi, float x, float y, float z);
	void GenerateFromObject(ge_Object* obj, float height, bool north, bool south, bool east, bool west, bool up, bool down, u8* verts[6], int** vi, float x, float y, float z);
	void FancyGrass(Block* block, float* tu, float *tv, int* biome_color, int xincr, int yincr);
	Block* block;
	Material* mat;
	Block* b_down;
	Client* client;
	Chunk* chunk;
	float side;
	Material* force_mat;
};
